package com.manli.api.util;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.math3.util.Pair;

import java.util.List;
import java.util.Map;

public class WeightRandomUtil {
    public static double kanjiaBili(){
        List<Pair<String, Integer>> list = Lists.newArrayList();
        list.add(new Pair("0.001", 7));
        list.add(new Pair("0.002", 7));
        list.add(new Pair("0.003", 7));
        list.add(new Pair("0.004", 7));
        list.add(new Pair("0.005", 7));
        list.add(new Pair("0.006", 7));
        list.add(new Pair("0.007", 3));
        list.add(new Pair("0.008", 3));
        list.add(new Pair("0.009", 3));
        list.add(new Pair("0.01", 3));

        WeightRandom<String, Integer> random = new WeightRandom(list);
        String randomKey = random.random();
        return Double.parseDouble(randomKey);
    }

    public static double kanjiaBili10(){
        List<Pair<String, Integer>> list = Lists.newArrayList();
        list.add(new Pair("0.01", 7));
        list.add(new Pair("0.02", 7));
        list.add(new Pair("0.03", 7));
        list.add(new Pair("0.04", 7));
        list.add(new Pair("0.05", 7));
        list.add(new Pair("0.06", 7));
        list.add(new Pair("0.07", 3));
        list.add(new Pair("0.08", 3));
        list.add(new Pair("0.09", 3));
        list.add(new Pair("0.1", 3));

        WeightRandom<String, Integer> random = new WeightRandom(list);
        String randomKey = random.random();
        return Double.parseDouble(randomKey);
    }

    public static void main(String[] args) {
        for(int i=0;i<100;i++){
            System.out.println(WeightRandomUtil.kanjiaBili());
        }
    }
}
